<?php

extract(array(
	'extra_class' => '',
	'small_icons' => true,
	'show_title' => true,
	'shorten_title' => 0,
	'show_image' => true,
	'image_width' => 70,
	'image_height' => 70,
	'show_rewards' => true,
	'show_friendship' => false,
	'show_notification' => false,
	'num_rewards' => 2,
	'layout' => array('image', 'title', 'notifications', 'friendship', 'rewards'),
), EXTR_SKIP);

if ( !empty($user) ) : ?>

<div class="user-info <?php echo $extra_class ?>" id="user-info-<?php echo $user->user_id ?>">
	
	<?php foreach ($layout as $l) {
		
		switch ($l) {
			case 'image':
				if ( $show_image ) {

					printf('<a class="thumbnail" href="%s">', $user->profileUrl);
					$this->renderPartial('//common/image', array('pair' => $user->avatar, 'object_type' => 'user', 'no_link' => true, 'width' => $image_width, 'height' => $image_height));
					printf('</a>');

				}
				break;
				
			case 'upload_image':
				
				printf('<a rel="nofollow" class="cm-ajax change-avatar" rev="upload_avatar" title="Change profile picture" name="dialog" href="%s">%s</a>', $this->createUrl('/user/uploadAvatar'), '(Change your avatar)');
				
				break;
			
			case 'title':
				if ( $show_title ) {
					
					printf('<h4 class="name"><a href="%s">%s</a></h4>', $user->profileUrl, userDisplayName($user));

				}
				break;
				
			case 'notifications':
				if ( $show_notification && $user->user_id == user()->id ) {

					printf('<div class="user-notifications">');
					printf('<a rel="nofollow" href="%s"><span class="message-notification">%d</span></a>', $this->createUrl('/user/notifications/'), $user->countNotification());
					printf('</div>');

				}
				break;
				
			case 'friendship':
				if ( $show_friendship && $user->user_id != user()->id ) {

					if ( $user->isFriend(user()->id) ) {
						
						printf('<a class="friend was-friend">Already your friend</a>');
						
					} else {
						
						if ( $user->requestedFriend(user()->id) ) {
							printf('<a class="friend friend-requested">Already send make friend request.</a>');
						} else {
							printf('<a rel="nofollow" href="%s" rev="user-info-'.$user->user_id.'" class="cm-ajax friend add-friend"><i class="icon-friend"></i>Invite</a>', $user->friendUrl);
						}
						
					}

				}
				break; 
		}
	} ?>
	
<!--user-info-<?php echo $user->user_id ?>--></div>

<?php endif; ?>